package com.program.controller;

import com.program.common.ResultData;
import com.program.service.TestService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@Api("测试Controller")
@RequestMapping("EC")
@RestController
public class ExampleController {

    @Autowired
    private TestService testService;

    @ApiOperation(value = "示例接口", notes = "示例接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "param", value = "参数", dataType = "String", paramType = "form") })
    @RequiresRoles(value={"user","admin"}, logical= Logical.OR) //属于user或者admin之一;修改logical为OR 即可
    @RequestMapping("example")
    @ResponseBody
    public ResultData example(@RequestParam("param")String param){
        testService.example(param);
        return ResultData.success(param);
    }

}
